const MyPromise = require("./MyPromise")
const promise = new MyPromise((resolve,reject)=>{
    setTimeout(() => {
        resolve('success')
    }, 2000);
    // resolve('success')

    // reject('err')
    // throw new Error('执行器错误')
})

function other(){
    return new MyPromise((resolve,reject)=>{
        resolve('other')
    })
}

promise.then(value=>{
    console.log(1)
    console.log('resolve',value) 
    // return other()
    throw new Error('error')

}, reason=>{
    console.log(2)
    console.log('reject',reason)
}).then(value=>{
    console.log(3)
    console.log('resolve',value) 
    // return other()
}, reason=>{
    console.log(4)
    console.log('reject',reason.message)
})


// promise.then(value=>{
//     console.log(2)
//     console.log('resolve',value)
// }, reason=>{
//     console.log('reject',reason)
// })


// promise.then(value=>{
//     console.log(3)
//     console.log('resolve',value)
// }, reason=>{
//     console.log('reject',reason)
// })